type optionType = {
    method: string,
    url: string,
    delay?: number
}
export default function xwAxios ({method, url, delay=2000}:optionType) {
    return new Promise((resolve) => {
        const xhr = new XMLHttpRequest()
        xhr.open(method, url)
        xhr.onreadystatechange = (e) => {
            console.log(e)
            console.log('xhr',xhr);
            
            if(xhr.readyState == 4 && xhr.status === 200) {
                    const data = JSON.parse(xhr.response)
                    setTimeout(() => {
                    resolve(data)
                },delay)
            }
            
        }
            xhr.send()
    })
}